package com.dmooo.ymx.merchantadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dmooo.ymx.R;
import com.dmooo.ymx.merchantbean.NearByCortItem;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 下拉选框右边
 * Created by cc on 2017/12/28.
 */

public class NearByRightMenuAdapter extends BaseAdapter {

    Context context;
    List<NearByCortItem> lists;
    ViewHolder viewHolder;
    Map<Integer,Object> mapview=new HashMap<>();
    public NearByRightMenuAdapter(Context context){
        this.context=context;
    }

    public void addList(List<NearByCortItem> lists){
        this.lists=lists;
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int i) {
        return lists.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (mapview.get(i)==null){
            viewHolder=new ViewHolder();
            LayoutInflater inflater =LayoutInflater.from(context);
            view=inflater.inflate(R.layout.item_popwindow_left_item,null);
            viewHolder.textView=view.findViewById(R.id.tv_menu);
        }else {
            view= (View) mapview.get(i);
            viewHolder= (ViewHolder) view.getTag();
        }
        NearByCortItem items=lists.get(i);
        viewHolder.textView.setText(items.getName());
        return view;
    }

    class ViewHolder{
        TextView textView;
    }
}
